Configuration, compilation and getting started with the software:
3.6. Q - How is the cdbx utility used for debugging?
A - The cdbx utility is used when we need to add serial output debugging lines to the code.
The debugging code exists in the source file as comments so we don't have to alter the
source code and add bugs.
The first thing to do is put a:
// !dbgen on
line on the top of the source file. If this line reads:
// !dbgen off
the file will not be preprocessed.
Now, when we get to a line that we need debug info on,
we can do this:
//
// This is a normal c statement line
i = 0;
// Now we print the value of i before and after the function call
//!dbi i
i++;
//!dbi i
When the program gets to this section the following will be printed on the serial port:
[0000][0001]
Note the four digit representation of the value which is in brackets.
// We can even do something more complex
//!dbs "Value of of i before,after is: "
//!dbi i
i++;
//!dbs ","
//!dbi i
//!dbs "\r\n"
When the program gets to this section the following will be printed on the serial port:
Value of i before,after is: [0000],[0001]
The ccpicc program will use the cdbx utility to prepossess the source file and then
perform the compile.
Please note that the source program is never changed.